package effective.enumannotaion;

import java.util.EnumMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Herb {

	enum Type {
		ANNUAL, PERENNIAL, BIENNIAL
	}

	private final String name;
	private final Type type;

	private Herb(String name, Type type) {
		super();
		this.name = name;
		this.type = type;
	}

	@Override
	public String toString() {
		return name;
	}

	public void orinal(Set<Herb> garden) {
		Map<Herb.Type, Set<Herb>> herbsByType = new EnumMap<Herb.Type, Set<Herb>>(
				Herb.Type.class);
		for (Herb.Type t : Herb.Type.values()) {
			herbsByType.put(t, new HashSet<Herb>());
		}

		for (Herb h : garden) {
			herbsByType.get(h.type).add(h);
		}
		System.out.println(herbsByType);
	}

}
